VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "clscMessages"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit

Private colData As New Collection

'Requred property (or function)
Public Property Get Item(Index) As clsMessage
Set Item = colData(Index)
End Property

'Requred property (or function)
Public Property Get Count()
Count = colData.Count
End Property

Public Sub Add(NewItem As clsMessage)
colData.Add NewItem
End Sub
Public Sub Create(Optional Parent)

Dim rs As Recordset
Dim qd As QueryDef
Dim qdChildren As QueryDef
Dim rsChilren As Recordset
Dim i As Integer
Dim lngParentID As Long
Dim msgItem As clsMessage

If IsMissing(Parent) Then 'Top level
    lngParentID = 0
  Else
    lngParentID = Parent.ID
End If

    Set qd = dbMain.QueryDefs("Messages")
    qd.Parameters(0) = lngParentID
    Set rs = qd.OpenRecordset()
    
    rs.MoveLast
    rs.MoveFirst
    
    For i = 1 To rs.RecordCount
        Set msgItem = New clsMessage
        
        With msgItem
            .Subject = rs!Subject & ""
            .Sender = rs!Sender & ""
            .DateSent = rs!DateSent
            .Message = rs!Message
            .HasChildren = rs!HasChildren
            .ID = rs!MessageID
        End With
        
        colData.Add msgItem
        rs.MoveNext
    Next i
    
    rs.Close
    

    

End Sub

Private Sub Class_Initialize()
If dbMain Is Nothing Then Set dbMain = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\Sample")
End Sub

